<?php

/**
 * This is the model class for table "cs_reback".
 *
 * The followings are the available columns in table 'cs_reback':
 * @property integer $id
 * @property string $flightNo
 * @property string $deptAirportCode
 * @property string $destAirportCode
 * @property string $planDepartTime
 * @property string $planArriveTime
 * @property string $actulDepartTime
 * @property string $actulArriveTime
 * @property string $cancelTime
 * @property string $flightStatus
 * @property string $delayTime
 * @property integer $create_time
 * @property integer $has_claim
 * @property integer $failure
 */
class Db2CsReback extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cs_reback';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('create_time, has_claim, failure', 'numerical', 'integerOnly'=>true),
			array('flightNo, deptAirportCode, destAirportCode, planDepartTime, planArriveTime, actulDepartTime, actulArriveTime, cancelTime, flightStatus, delayTime', 'length', 'max'=>45),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, flightNo, deptAirportCode, destAirportCode, planDepartTime, planArriveTime, actulDepartTime, actulArriveTime, cancelTime, flightStatus, delayTime, create_time, has_claim, failure', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'flightNo' => 'Flight No',
			'deptAirportCode' => 'Dept Airport Code',
			'destAirportCode' => 'Dest Airport Code',
			'planDepartTime' => 'Plan Depart Time',
			'planArriveTime' => 'Plan Arrive Time',
			'actulDepartTime' => 'Actul Depart Time',
			'actulArriveTime' => 'Actul Arrive Time',
			'cancelTime' => 'Cancel Time',
			'flightStatus' => 'Flight Status',
			'delayTime' => 'Delay Time',
			'create_time' => 'Create Time',
			'has_claim' => 'Has Claim',
			'failure' => 'Failure',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('flightNo',$this->flightNo,true);
		$criteria->compare('deptAirportCode',$this->deptAirportCode,true);
		$criteria->compare('destAirportCode',$this->destAirportCode,true);
		$criteria->compare('planDepartTime',$this->planDepartTime,true);
		$criteria->compare('planArriveTime',$this->planArriveTime,true);
		$criteria->compare('actulDepartTime',$this->actulDepartTime,true);
		$criteria->compare('actulArriveTime',$this->actulArriveTime,true);
		$criteria->compare('cancelTime',$this->cancelTime,true);
		$criteria->compare('flightStatus',$this->flightStatus,true);
		$criteria->compare('delayTime',$this->delayTime,true);
		$criteria->compare('create_time',$this->create_time);
		$criteria->compare('has_claim',$this->has_claim);
		$criteria->compare('failure',$this->failure);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * @return CDbConnection the database connection used for this class
	 */
	public function getDbConnection()
	{
		return Yii::app()->db2;
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Db2CsReback the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
